package com.example.demo.controller;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 获取配置文件
 * 使用@PropertySource("classpath:conf.yml")
 * @Value("${}")
 * @author jiaqi.liu
 *
 */
@RestController
@PropertySource("classpath:conf.yml")
public class PropsControllerDemo2 {
	
	
	@Value("${person.name}")
	private String name;
	
	@Value("${person.age}")
	private String age;
	
	
	@GetMapping("/getPropsMethodTwo")
	public Map<String,String> getPropsMethodTwo(){
		
		Map<String,String> map=new HashMap<String,String>();
		   map.put("name", name);
		   map.put("age", age);
		return map;
	}
}
